// pages/nurse/recordslist/recordslist.js
var api = require('../../../config/api.js');
const util = require('../../../utils/util.js');

Page({

  /**
   * 页面的初始数据
   */
  data: {
      record_lists: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      this.getRecordList();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  getRecordList: function () {
        let that = this;
       util.request(api.MaintainInfoList).then(function (res) {
        console.log("getRecordList" + JSON.stringify(res));
        var record_list_names_obj = res['data'];
         if (res.errno === 0) {
          for (var i = 0; i < record_list_names_obj.length; i++) {
              
            var record_list_name_todo='record_lists['+i+'].name';
            that.setData({
              [record_list_name_todo]:record_list_names_obj[i]['id']
            })
            var record_list_id_todo='record_lists['+i+'].id';
            that.setData({
              [record_list_id_todo]:record_list_names_obj[i]['id']
            })
            var record_list_time_todo='record_lists['+i+'].time';
            that.setData({
              [record_list_time_todo]:record_list_names_obj[i]['addTime']
            })
            var record_list_status_todo='record_lists['+i+'].punctureStatus';
            that.setData({
              [record_list_status_todo]:record_list_names_obj[i]['lienState']
            })
            var record_list_left_arm_todo='record_lists['+i+'].leftArmSize';
            that.setData({
              [record_list_left_arm_todo]:record_list_names_obj[i]['leftArmline']
            })
            var record_list_right_arm_todo='record_lists['+i+'].rightArmSize';
            that.setData({
              [record_list_right_arm_todo]:record_list_names_obj[i]['rightArmline']
            })
          }
          //that.setData({
           //  record_lists: res.data.record_lists
           //});
         }
       });
      /*that.setData({
        record_lists: [
          {
            id: 0,
            time: "2019/6/26 10:45",
            name: "王小明",
            leftArmSize: 10,
            rightArmSize: 10,
            punctureStatus: "已穿刺"
          },
          {
            id: 1,
            time: "2019/6/26 10:45",
            name: "王小明",
            leftArmSize: 10,
            rightArmSize: 10,
            punctureStatus: "已穿刺"
          },
          {
            id: 2,
            time: "2019/6/26 10:45",
            name: "王小明",
            leftArmSize: 10,
            rightArmSize: 10,
            punctureStatus: "已穿刺"
          },
          {
            id: 3,
            time: "2019/6/26 10:45",
            name: "王小明",
            leftArmSize: 10,
            rightArmSize: 10,
            punctureStatus: "已穿刺"
          },
          {
            id: 4,
            time: "2019/6/26 10:45",
            name: "王小明",
            leftArmSize: 10,
            rightArmSize: 10,
            punctureStatus: "已穿刺"
          }
        ]
      });*/
  }

})